package com.aiti.lulian.controller.newCard;

import com.aiti.base.core.base.controller.BaseController;
import com.aiti.base.core.utils.message.Message;
import com.aiti.lulian.dto.newCard.CardPrivacySettingDto;
import com.aiti.lulian.entity.newCard.CardPrivacySetting;
import com.aiti.lulian.service.CardPrivacySettingService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("new-card/privacy-setting")
public class CardPrivacySettingController extends BaseController {

    @Autowired
    private CardPrivacySettingService cardPrivacySettingService;

    @ApiOperation("修改隐私权限")
    @PutMapping
    public Message updatePrivacySetting(@RequestBody CardPrivacySettingDto dto) {
        return cardPrivacySettingService.updatePrivacySetting(dto);
    }

    @ApiOperation("查询隐私权限")
    @GetMapping
    public Message getPrivacySetting(@RequestParam("cardId") String cardId) {
        return Message.success(cardPrivacySettingService.getOne(new LambdaQueryWrapper<CardPrivacySetting>().eq(CardPrivacySetting::getCardId, cardId)));
    }
}
